<div class="card">
    <div class="card-block">
        <button type="button" class="btn btn-primary pull-left" onclick="back_to_list()"><i class="fa fa-arrow-left" /> 返回</button>
    </div>
    <div class="card-block">
        <form id="form1">
            <div class="form-group">
                <label for="name">角色名称</label>
                <input type="text" class="form-control" id="name" name="name" value="{name}" placeholder="4-20字符">
            </div>
            <div class="form-group">
                <label for="name">角色简介</label>
                <input type="text" class="form-control" id="content" name="content" value="{content}" placeholder="角色简介">
            </div>
            <div class="form-check">
                <p>权限列表</p>
                <hr />
                {permissions_list}
                <hr />
            </div>
            <button type="submit" class="btn btn-primary"><i class="fa fa-save" /> 保存</button>
            <input type="hidden" id="id" name="id" value="{id}">
        </form>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#form1").submit(function () {
            $.ajax({
                url: "?m=members&a=role_edit_save",
                type: "POST",
                data: $("#form1").serialize(),
                dataType: "json",
                error: function(xhr,textStatus){
                    alert(textStatus);
                },
                success: function (data,textStatus,jqXHR) {
                    if(data.status == "error") {
                        alert(data.msg);
                    } else {
                        back_to_list();
                    }
                }
            });
            return false;
        });
    });

    function back_to_list() {
        _goto("?m=members&a=role_list&page={page}");
    }
</script>